package com.salesystem.strust.action;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.salesystem.dao.entity.Employee;
import com.salesystem.dao.interfaces.EmployeeBiz;
import com.salesystem.util.Pagination;

/***
 * 员工Action类
 * @author 兰雪颖 
 *
 * Jun 21, 2011
 */
@Controller
@Scope("prototype")
public class EmployeeAction {
	@Resource 
	private EmployeeBiz employeeService ;
	private List<Employee> Employees ;
	private Employee employee ;
	private Pagination pagination; 
    private Integer pageNo = 1;
    private String url = "employee_list.do" ;
	public EmployeeBiz getEmployeeService() {
		return employeeService;
	}
	public void setEmployeeService(EmployeeBiz employeeService) {
		this.employeeService = employeeService;
	}
	public List<Employee> getEmployees() {
		return Employees;
	}
	public void setEmployees(List<Employee> employees) {
		Employees = employees;
	}
	public Employee getEmployee() {
		return employee;
	}
	public void setEmployee(Employee employee) {
		this.employee = employee;
	}
	public Pagination getPagination() {
		return pagination;
	}
	public void setPagination(Pagination pagination) {
		this.pagination = pagination;
	}
	public Integer getPageNo() {
		return pageNo;
	}
	public void setPageNo(Integer pageNo) {
		this.pageNo = pageNo;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
    
	/**  
     * 员工信息列表显示  
     */   
    public String list(){ 
        this.Employees = employeeService.getEmployeeList();  
        pagination = new Pagination(pageNo,12,Employees.size(),5, url,"pagenum");
        Employees = pagination.getPageDate(Employees);
        return "list";   
    }  
	/**
     * 员工信息查看
     */
    public String view(){
    	this.employee = employeeService.viewEmployee(employee.getId());
    	return "view" ;
    }
    /**  
     * 员工信息添加界面  
     */   
    public String addEP(){   
        return "addEP";   
    }   
    /**  
     * 员工信息添加  
     */   
    public String add(){
    	this.employee = employeeService.viewEmployee(employee.getId());
    	employeeService.save(this.employee);   
        return "addsuccess";   
    }
    /**  
     * 员工信息修改界面  
     */  
    public String editEP(){
    	this.employee = employeeService.viewEmployee(employee.getId());
    	return "editEP" ;
    }
    /**  
     * 招聘信息修改  
     */   
    public String edit(){
    	Employee employee = new Employee();
    	this.employee = employeeService.viewEmployee(employee.getId());
    	employeeService.modifyEmployee(employee);      
        return "editsuccess";   
    }
    /**  
     * 招聘信息删除  
     */
    public String delEP(){
    	employeeService.delEmployee(employee.getId());
        return "delsuccess"; 
    }    
}
